$(function () {
    var self=this;
    $("th").has("i").each(function (i, item) {
    $(this).css("cursor", "pointer");
    $(this).attr("title", "点击按 " + $(this).text() + " 进行排序");

    });


    $(document).on("click", "th i",function () {

    //var noField = $(this).attr("lang");//排序字段类型  11-4  noField存在为 非数据库字段排序

    var iSort = $(this);
    var sortName = iSort.attr("data-sort");
    var sortDirect = iSort.attr("data-sort-direct");

    if (sortDirect == "asc") {
        sortDirect = "desc";
    }
    else if (sortDirect == "desc") {
        sortDirect = "asc";
    }else{
    	sortDirect = "asc";
    }

    iSort.attr("data-sort-direct", sortDirect);
    iSort.removeClass("sort_asc").removeClass("sort_desc").removeClass("sort_normal");
    iSort.addClass("sort_" + sortDirect);

    $("th i").not(iSort).removeClass("sort_asc").removeClass("sort_desc").removeClass("sort_normal");
    $("th i").not(iSort).removeAttr("data-sort-direct");
    var dataType = iSort.attr("data-type");
    if(dataType=='zhi'){
        $("th i[data-type='zhi']").addClass("sort_" + sortDirect).attr("data-sort-direct", sortDirect);
    }else if(dataType=='shou'){
        $("th i[data-type='shou']").addClass("sort_" + sortDirect).attr("data-sort-direct", sortDirect);
    }else {
        $("th i[data-sort='" + sortName + "']").addClass("sort_" + sortDirect).attr("data-sort-direct", sortDirect);
    }


    var p = getParamer();
    isSearching = true;
    var pageSize = 50;//500
    var sort = $("th i[data-sort-direct]");
    if (p && sort.length > 0 && sort.attr("data-sort-direct")) {
        p["SortColumn"] = sort.attr("data-sort");
        p["SortDirect"] = sort.attr("data-sort-direct");
    }


        sort_startSearch(p);//直接库存搜索 9-14   //数据库字段排序
    });
});
